<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>企业货运风险分析工具</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        
        body {
            background: linear-gradient(135deg, #f5f7fa 0%, #e4edf9 100%);
            color: #333;
            line-height: 1.6;
            padding: 20px;
            min-height: 100vh;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
            background: white;
            border-radius: 15px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
            overflow: hidden;
        }
        
        header {
            background: linear-gradient(90deg, #2c3e50 0%, #3498db 100%);
            color: white;
            padding: 30px 40px;
            text-align: center;
        }
        
        h1 {
            font-size: 2.5rem;
            margin-bottom: 10px;
            font-weight: 700;
        }
        
        .subtitle {
            font-size: 1.2rem;
            opacity: 0.9;
            max-width: 800px;
            margin: 0 auto;
        }
        
        .main-content {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 30px;
            padding: 30px;
        }
        
        @media (max-width: 900px) {
            .main-content {
                grid-template-columns: 1fr;
            }
        }
        
        .panel {
            background: white;
            border-radius: 12px;
            box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
            padding: 30px;
            transition: transform 0.3s, box-shadow 0.3s;
        }
        
        .panel:hover {
            transform: translateY(-5px);
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
        }
        
        .panel-header {
            display: flex;
            align-items: center;
            margin-bottom: 25px;
            padding-bottom: 15px;
            border-bottom: 2px solid #f0f5ff;
        }
        
        .panel-icon {
            width: 50px;
            height: 50px;
            background: #3498db;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 15px;
            color: white;
            font-size: 1.5rem;
        }
        
        .panel-title {
            font-size: 1.8rem;
            color: #2c3e50;
        }
        
        .form-section {
            margin-bottom: 30px;
        }
        
        .form-section h3 {
            font-size: 1.4rem;
            margin-bottom: 15px;
            color: #3498db;
            display: flex;
            align-items: center;
        }
        
        .form-section h3 i {
            margin-right: 10px;
        }
        
        .form-group {
            margin-bottom: 20px;
        }
        
        label {
            display: block;
            margin-bottom: 8px;
            font-weight: 500;
            color: #2c3e50;
            font-size: 1.1rem;
        }
        
        .input-row {
            display: flex;
            gap: 15px;
            margin-bottom: 15px;
        }
        
        .input-group {
            flex: 1;
        }
        
        input[type="text"],
        input[type="number"],
        input[type="time"],
        select,
        textarea {
            width: 100%;
            padding: 14px;
            border: 1px solid #d9e2ef;
            border-radius: 8px;
            font-size: 1rem;
            background: #f8fafd;
            transition: all 0.3s;
        }
        
        input:focus, select:focus, textarea:focus {
            outline: none;
            border-color: #3498db;
            box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
            background: white;
        }
        
        .time-input {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .time-input input {
            flex: 1;
        }
        
        .checkbox-group, .radio-group {
            display: flex;
            flex-wrap: wrap;
            gap: 15px;
            margin-top: 8px;
        }
        
        .checkbox-item, .radio-item {
            display: flex;
            align-items: center;
            background: #f8fafd;
            padding: 10px 15px;
            border-radius: 8px;
            transition: all 0.2s;
        }
        
        .checkbox-item:hover, .radio-item:hover {
            background: #e3f2fd;
            transform: translateY(-2px);
        }
        
        .checkbox-item input, .radio-item input {
            margin-right: 8px;
            width: 20px;
            height: 20px;
        }
        
        button {
            background: linear-gradient(90deg, #3498db 0%, #1f6bc5 100%);
            color: white;
            border: none;
            padding: 16px 30px;
            font-size: 1.1rem;
            border-radius: 50px;
            cursor: pointer;
            display: block;
            margin: 30px auto;
            transition: all 0.3s;
            font-weight: 500;
            width: 100%;
            max-width: 300px;
            box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3);
        }
        
        button:hover {
            transform: translateY(-3px);
            box-shadow: 0 7px 15px rgba(52, 152, 219, 0.4);
            background: linear-gradient(90deg, #3498db 0%, #1a5ca9 100%);
        }
        
        button:active {
            transform: translateY(1px);
        }
        
        .download-btn {
            background: linear-gradient(90deg, #27ae60 0%, #219653 100%);
            box-shadow: 0 4px 10px rgba(39, 174, 96, 0.3);
        }
        
        .download-btn:hover {
            background: linear-gradient(90deg, #27ae60 0%, #1a8043 100%);
            box-shadow: 0 7px 15px rgba(39, 174, 96, 0.4);
        }
        
        .result-container {
            margin-top: 30px;
            display: none;
        }
        
        .risk-score {
            text-align: center;
            margin: 20px 0;
            font-size: 1.3rem;
        }
        
        .score-value {
            font-size: 3rem;
            font-weight: 700;
            margin: 10px 0;
        }
        
        .score-low { color: #27ae60; }
        .score-medium { color: #f39c12; }
        .score-high { color: #e74c3c; }
        
        .risk-section {
            margin-bottom: 30px;
            padding: 20px;
            border-radius: 10px;
            background: #f8fafd;
        }
        
        .risk-section h3 {
            display: flex;
            align-items: center;
            margin-bottom: 15px;
            font-size: 1.4rem;
            color: #2c3e50;
        }
        
        .risk-section h3 i {
            margin-right: 10px;
            color: #3498db;
        }
        
        .risk-factors {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
            gap: 15px;
        }
        
        .risk-factor {
            padding: 15px;
            border-radius: 8px;
            background: white;
            box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
        }
        
        .factor-header {
            display: flex;
            align-items: center;
            margin-bottom: 10px;
        }
        
        .factor-icon {
            width: 30px;
            height: 30px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 10px;
            color: white;
        }
        
        .factor-critical { background: #e74c3c; }
        .factor-high { background: #f39c12; }
        .factor-medium { background: #3498db; }
        .factor-low { background: #27ae60; }
        
        .prevention-suggestions ul {
            padding-left: 25px;
            margin-bottom: 15px;
        }
        
        .prevention-suggestions li {
            margin-bottom: 12px;
            line-height: 1.6;
        }
        
        .detail-card {
            background: white;
            border-left: 5px solid #3498db;
            padding: 15px;
            margin: 15px 0;
            border-radius: 0 8px 8px 0;
            box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
        }
        
        .risk-calendar {
            display: grid;
            grid-template-columns: repeat(6, 1fr);
            gap: 10px;
            margin-top: 20px;
        }
        
        .month-box {
            padding: 15px 10px;
            text-align: center;
            border-radius: 8px;
            font-weight: 600;
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        
        .month-name {
            margin-bottom: 8px;
            font-size: 0.9rem;
        }
        
        .risk-tag {
            padding: 4px 10px;
            border-radius: 50px;
            font-size: 0.85rem;
        }
        
        .low-risk { 
            background-color: rgba(39, 174, 96, 0.15);
            color: #27ae60;
        }
        .medium-risk { 
            background-color: rgba(243, 156, 18, 0.15);
            color: #f39c12;
        }
        .high-risk { 
            background-color: rgba(231, 76, 60, 0.15);
            color: #e74c3c;
        }
        
        .priority-box {
            background: #fff8e1;
            border-left: 5px solid #ffc107;
            padding: 15px;
            margin: 20px 0;
            border-radius: 0 8px 8px 0;
        }
        
        .risk-badge {
            display: inline-block;
            padding: 4px 10px;
            border-radius: 50px;
            font-size: 0.85rem;
            font-weight: 500;
            margin-right: 8px;
        }
        
        footer {
            text-align: center;
            padding: 20px;
            color: #7f8c8d;
            font-size: 0.9rem;
            margin-top: 40px;
            border-top: 1px solid #eee;
        }
        
        .empty-state {
            text-align: center;
            padding: 50px 20px;
            color: #7f8c8d;
        }
        
        .empty-state i {
            font-size: 4rem;
            margin-bottom: 20px;
            color: #bdc3c7;
        }
        
        .empty-state h3 {
            margin-bottom: 10px;
        }
        
        @media print {
            .no-print, button {
                display: none;
            }
            body {
                background: white;
                padding: 0;
            }
            .panel {
                box-shadow: none;
                border: 1px solid #eee;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <h1><i class="fas fa-truck-loading"></i> 企业货运风险分析工具</h1>
            <p class="subtitle">全面评估企业货运活动风险，生成针对性事故预防策略</p>
        </header>
        
        <div class="main-content">
            <div class="panel">
                <div class="panel-header">
                    <div class="panel-icon">
                        <i class="fas fa-clipboard-list"></i>
                    </div>
                    <h2 class="panel-title">风险因素评估</h2>
                </div>
                
                <div class="form-section">
                    <h3><i class="fas fa-industry"></i> 企业基本信息</h3>
                    <div class="input-row">
                        <div class="input-group">
                            <label for="company-name">企业名称</label>
                            <input type="text" id="company-name" placeholder="请输入企业全称">
                        </div>
                        <div class="input-group">
                            <label for="employee-count">员工规模</label>
                            <input type="number" id="employee-count" placeholder="员工数量">
                        </div>
                    </div>
                    
                    <div class="form-group">
                        <label for="industry">所属行业</label>
                        <select id="industry">
                            <option value="">请选择行业</option>
                            <option value="manufacturing">制造业</option>
                            <option value="logistics">物流仓储</option>
                            <option value="construction">建筑工程</option>
                            <option value="chemical">化工行业</option>
                            <option value="retail">零售电商</option>
                            <option value="other">其他</option>
                        </select>
                    </div>
                    
                    <div class="form-group">
                        <label for="location-type">厂区位置类型</label>
                        <div class="radio-group">
                            <div class="radio-item">
                                <input type="radio" id="location-urban" name="location" value="urban">
                                <label for="location-urban">城市工业区</label>
                            </div>
                            <div class="radio-item">
                                <input type="radio" id="location-suburb" name="location" value="suburb" checked>
                                <label for="location-suburb">郊区工业区</label>
                            </div>
                            <div class="radio-item">
                                <input type="radio" id="location-rural" name="location" value="rural">
                                <label for="location-rural">农村/偏远地区</label>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="form-section">
                    <h3><i class="fas fa-truck-moving"></i> 货运活动特征</h3>
                    <div class="input-row">
                        <div class="input-group">
                            <label for="annual-volume">年货运量(吨)</label>
                            <input type="number" id="annual-volume" placeholder="请输入年货运量">
                        </div>
                        <div class="input-group">
                            <label for="fleet-size">自有货车数量</label>
                            <input type="number" id="fleet-size" placeholder="自有车辆数">
                        </div>
                    </div>
                    
                    <div class="form-group">
                        <label>高峰月份</label>
                        <div class="input-row">
                            <div class="input-group">
                                <label for="peak-in-month">主要进货月</label>
                                <select id="peak-in-month">
                                    <option value="">请选择月份</option>
                                    <option value="1">1月</option>
                                    <option value="2">2月</option>
                                    <option value="3">3月</option>
                                    <option value="4">4月</option>
                                    <option value="5">5月</option>
                                    <option value="6">6月</option>
                                    <option value="7">7月</option>
                                    <option value="8">8月</option>
                                    <option value="9" selected>9月</option>
                                    <option value="10">10月</option>
                                    <option value="11">11月</option>
                                    <option value="12">12月</option>
                                </select>
                            </div>
                            <div class="input-group">
                                <label for="peak-out-month">主要出货月</label>
                                <select id="peak-out-month">
                                    <option value="">请选择月份</option>
                                    <option value="1">1月</option>
                                    <option value="2">2月</option>
                                    <option value="3">3月</option>
                                    <option value="4">4月</option>
                                    <option value="5">5月</option>
                                    <option value="6">6月</option>
                                    <option value="7">7月</option>
                                    <option value="8">8月</option>
                                    <option value="9">9月</option>
                                    <option value="10" selected>10月</option>
                                    <option value="11">11月</option>
                                    <option value="12">12月</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    
                    <div class="form-group">
                        <label>运输时段特征</label>
                        <div class="input-row">
                            <div class="input-group">
                                <label for="morning-start">早高峰进货</label>
                                <div class="time-input">
                                    <input type="time" id="morning-start" value="07:00">
                                    <span>至</span>
                                    <input type="time" id="morning-end" value="09:00">
                                </div>
                            </div>
                            <div class="input-group">
                                <label for="evening-start">晚高峰出货</label>
                                <div class="time-input">
                                    <input type="time" id="evening-start" value="16:00">
                                    <span>至</span>
                                    <input type="time" id="evening-end" value="19:00">
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="form-group">
                        <label>特殊高峰时段</label>
                        <div class="checkbox-group">
                            <div class="checkbox-item">
                                <input type="checkbox" id="month-end" checked>
                                <label for="month-end">月末高峰</label>
                            </div>
                            <div class="checkbox-item">
                                <input type="checkbox" id="quarter-end">
                                <label for="quarter-end">季末高峰</label>
                            </div>
                            <div class="checkbox-item">
                                <input type="checkbox" id="before-holiday">
                                <label for="before-holiday">节假日前高峰</label>
                            </div>
                            <div class="checkbox-item">
                                <input type="checkbox" id="night-shift">
                                <label for="night-shift">夜间作业(22:00-6:00)</label>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="form-section">
                    <h3><i class="fas fa-road"></i> 道路环境特征</h3>
                    <div class="form-group">
                        <label for="road-type">厂区周边主要道路类型</label>
                        <select id="road-type">
                            <option value="">请选择道路类型</option>
                            <option value="highway">高速公路连接线</option>
                            <option value="national">国道/省道</option>
                            <option value="urban" selected>城市主干道</option>
                            <option value="rural">县乡道路</option>
                            <option value="mixed">混合道路</option>
                        </select>
                    </div>
                    
                    <div class="form-group">
                        <label for="intersections">主要路口/风险点数量</label>
                        <input type="number" id="intersections" placeholder="高风险路口数量" value="3">
                    </div>
                    
                    <div class="form-group">
                        <label for="pedestrian">人车混行区域</label>
                        <div class="radio-group">
                            <div class="radio-item">
                                <input type="radio" id="pedestrian-high" name="pedestrian" value="high">
                                <label for="pedestrian-high">大量混行</label>
                            </div>
                            <div class="radio-item">
                                <input type="radio" id="pedestrian-medium" name="pedestrian" value="medium" checked>
                                <label for="pedestrian-medium">部分混行</label>
                            </div>
                            <div class="radio-item">
                                <input type="radio" id="pedestrian-low" name="pedestrian" value="low">
                                <label for="pedestrian-low">基本分离</label>
                            </div>
                        </div>
                    </div>
                    
                    <div class="form-group">
                        <label for="accident-history">近3年事故记录</label>
                        <textarea id="accident-history" placeholder="简要描述近3年发生的事故情况，包括事故类型、时间、原因等" rows="3"></textarea>
                    </div>
                </div>
                
                <button id="analyze-btn"><i class="fas fa-chart-bar"></i> 开始风险分析</button>
            </div>
            
            <div class="panel">
                <div class="panel-header">
                    <div class="panel-icon">
                        <i class="fas fa-file-contract"></i>
                    </div>
                    <h2 class="panel-title">风险分析报告</h2>
                </div>
                
                <div class="result-container" id="result-container">
                    <div class="risk-score">
                        <h3><i class="fas fa-shield-alt"></i> 综合安全风险评估</h3>
                        <div id="risk-level" class="score-value score-medium">中风险</div>
                        <div class="risk-badge score-medium">风险评分: <span id="risk-score-value">64</span>/100</div>
                        <p>基于您提供的数据分析得出</p>
                    </div>
                    
                    <div class="risk-section">
                        <h3><i class="fas fa-calendar-alt"></i> 月度风险分布</h3>
                        <div class="risk-calendar" id="risk-calendar">
                            <!-- 风险日历将由JS生成 -->
                        </div>
                    </div>
                    
                    <div class="risk-section">
                        <h3><i class="fas fa-exclamation-triangle"></i> 关键风险因素分析</h3>
                        <div class="risk-factors" id="risk-factors">
                            <!-- 风险因素将由JS生成 -->
                        </div>
                    </div>
                    
                    <div class="priority-box">
                        <h3><i class="fas fa-bolt"></i> 高优先级防控措施</h3>
                        <p><i class="fas fa-arrow-circle-right"></i> <strong>盲区监控系统</strong>：在货车出入口安装智能盲区监控设备，减少内轮差事故风险</p>
                        <p><i class="fas fa-arrow-circle-right"></i> <strong>高峰时段限速</strong>：在17:00-19:00期间设置20km/h限速区，强制车辆慢行</p>
                        <p><i class="fas fa-arrow-circle-right"></i> <strong>夜间照明升级</strong>：在事故高发点增加2000流明以上高亮度LED照明</p>
                    </div>
                    
                    <div class="risk-section">
                        <h3><i class="fas fa-lightbulb"></i> 综合防控建议</h3>
                        <div class="prevention-suggestions" id="prevention-suggestions">
                            <!-- 防控建议将由JS生成 -->
                        </div>
                    </div>
                    
                    <div class="risk-section">
                        <h3><i class="fas fa-road"></i> 道路环境优化建议</h3>
                        <div id="road-suggestions">
                            <!-- 道路建议将由JS生成 -->
                        </div>
                    </div>
                    
                    <div class="risk-section">
                        <h3><i class="fas fa-clock"></i> 行动计划时间表</h3>
                        <div class="detail-card">
                            <p><strong>第一周：</strong> 完成盲点区域排查，制定整改方案</p>
                            <p><strong>第一个月：</strong> 安装减速带和警示标识，完成初步改造</p>
                            <p><strong>第一季度：</strong> 实施驾驶员安全培训计划，覆盖所有驾驶员</p>
                            <p><strong>上半年：</strong> 建立近事故报告系统，持续监测风险点</p>
                        </div>
                    </div>
                    
                    <button class="download-btn" id="download-btn"><i class="fas fa-download"></i> 下载完整风险报告</button>
                </div>
                
                <div class="empty-state" id="empty-state">
                    <i class="fas fa-file-alt"></i>
                    <h3>尚未生成风险评估报告</h3>
                    <p>请填写左侧表单后点击"开始风险分析"按钮</p>
                    <p>系统将根据您提供的数据生成定制化安全策略</p>
                </div>
            </div>
        </div>
        
        <footer>
            <p>本系统提供的信息仅供参考，具体安全措施请咨询专业安全顾问</p>
            <p>数据安全承诺：您输入的所有信息仅用于风险评估，不会被存储或共享</p>
        </footer>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const analyzeBtn = document.getElementById('analyze-btn');
            const downloadBtn = document.getElementById('download-btn');
            const resultContainer = document.getElementById('result-container');
            const emptyState = document.getElementById('empty-state');
            
            // 初始化风险日历
            generateRiskCalendar('9', '10');
            
            analyzeBtn.addEventListener('click', function() {
                // 获取表单数据
                const formData = {
                    company: document.getElementById('company-name').value || '未命名企业',
                    employees: parseInt(document.getElementById('employee-count').value) || 0,
                    industry: document.getElementById('industry').value,
                    location: document.querySelector('input[name="location"]:checked')?.value || 'suburb',
                    volume: parseInt(document.getElementById('annual-volume').value) || 0,
                    fleet: parseInt(document.getElementById('fleet-size').value) || 0,
                    inMonth: document.getElementById('peak-in-month').value,
                    outMonth: document.getElementById('peak-out-month').value,
                    morningStart: document.getElementById('morning-start').value,
                    morningEnd: document.getElementById('morning-end').value,
                    eveningStart: document.getElementById('evening-start').value,
                    eveningEnd: document.getElementById('evening-end').value,
                    roadType: document.getElementById('road-type').value,
                    intersections: parseInt(document.getElementById('intersections').value) || 0,
                    pedestrian: document.querySelector('input[name="pedestrian"]:checked')?.value || 'medium',
                    accidents: document.getElementById('accident-history').value,
                    monthEnd: document.getElementById('month-end').checked,
                    quarterEnd: document.getElementById('quarter-end').checked,
                    holiday: document.getElementById('before-holiday').checked,
                    nightShift: document.getElementById('night-shift').checked
                };
                
                // 验证必填字段
                if (!formData.inMonth || !formData.outMonth) {
                    alert('请至少填写最大进货月份和最大出货月份');
                    return;
                }
                
                // 执行风险分析
                const analysis = performRiskAnalysis(formData);
                
                // 显示结果
                displayAnalysisResults(analysis);
                
                // 隐藏空状态，显示结果
                emptyState.style.display = 'none';
                resultContainer.style.display = 'block';
                
                // 滚动到结果区域
                resultContainer.scrollIntoView({ behavior: 'smooth' });
            });
            
            downloadBtn.addEventListener('click', function() {
                // 生成报告内容
                const reportContent = generateReportContent();
                
                // 创建Blob对象
                const blob = new Blob([reportContent], { type: 'text/html' });
                
                // 创建下载链接
                const downloadLink = document.createElement('a');
                const companyName = document.getElementById('company-name').value || '企业货运';
                downloadLink.download = `${companyName}货运风险评估报告.html`;
                downloadLink.href = URL.createObjectURL(blob);
                downloadLink.style.display = 'none';
                
                // 添加到文档并触发下载
                document.body.appendChild(downloadLink);
                downloadLink.click();
                
                // 清理
                setTimeout(() => {
                    document.body.removeChild(downloadLink);
                    URL.revokeObjectURL(downloadLink.href);
                }, 100);
            });
            
            function performRiskAnalysis(data) {
                let riskScore = 30; // 基础分
                const riskFactors = [];
                const suggestions = [];
                const roadSuggestions = [];
                
                // 行业风险
                if (data.industry === 'chemical') {
                    riskScore += 25;
                    riskFactors.push({
                        name: '行业特性风险',
                        level: 'critical',
                        desc: '化工行业涉及危险品运输，事故后果严重性高',
                        weight: '高'
                    });
                    suggestions.push('建立危险品运输专项管理流程，配备专业应急设备');
                } else if (data.industry === 'logistics') {
                    riskScore += 15;
                    riskFactors.push({
                        name: '高频运输风险',
                        level: 'high',
                        desc: '物流企业车辆活动频繁，暴露风险增加',
                        weight: '中高'
                    });
                    suggestions.push('引入车联网系统实时监控车辆状态和驾驶员行为');
                }
                
                // 货运量风险
                if (data.volume > 100000) {
                    riskScore += 20;
                    riskFactors.push({
                        name: '大型货运规模',
                        level: 'high',
                        desc: `年货运量${data.volume}吨，远超行业平均水平`,
                        weight: '高'
                    });
                } else if (data.volume > 50000) {
                    riskScore += 15;
                    riskFactors.push({
                        name: '中等货运规模',
                        level: 'medium',
                        desc: `年货运量${data.volume}吨，高于行业平均值`,
                        weight: '中'
                    });
                }
                
                // 高峰时段风险
                const eveningStartHour = parseInt(data.eveningStart.split(':')[0]);
                const eveningEndHour = parseInt(data.eveningEnd.split(':')[0]);
                if (eveningStartHour >= 17 && eveningEndHour >= 19) {
                    riskScore += 18;
                    riskFactors.push({
                        name: '高峰时段重叠',
                        level: 'high',
                        desc: `晚高峰(${data.eveningStart}-${data.eveningEnd})与居民出行高峰重叠`,
                        weight: '高'
                    });
                    suggestions.push('<strong>潮汐式车道管理</strong>：在17:00-19:00期间增加执勤人员，分离货车与民用车辆');
                }
                
                // 夜间作业风险
                if (data.nightShift) {
                    riskScore += 15;
                    riskFactors.push({
                        name: '夜间作业风险',
                        level: 'high',
                        desc: '夜间作业能见度低，驾驶员疲劳风险增加',
                        weight: '高'
                    });
                    suggestions.push('<strong>疲劳驾驶预防</strong>：强制4小时休息制度，安装驾驶员状态监测设备');
                }
                
                // 道路环境风险
                if (data.roadType === 'rural') {
                    riskScore += 12;
                    roadSuggestions.push('<strong>道路安全升级</strong>：增设弯道反光镜，夜间反光标识，危险路段加装护栏');
                } else if (data.roadType === 'mixed') {
                    riskScore += 10;
                    roadSuggestions.push('<strong>交通组织优化</strong>：在混合道路增设物理隔离带，明确货车专用道');
                }
                
                if (data.pedestrian === 'high') {
                    riskScore += 15;
                    riskFactors.push({
                        name: '人车混行风险',
                        level: 'critical',
                        desc: '人车混行区域多，易发生行人事故',
                        weight: '极高'
                    });
                    suggestions.push('<strong>智能行人警示</strong>：在混行区域安装智能感应提示装置，提醒行人避让货车');
                }
                
                // 事故历史风险
                if (data.accidents) {
                    riskScore += Math.min(20, data.accidents.length * 5);
                    riskFactors.push({
                        name: '历史事故记录',
                        level: 'high',
                        desc: '过往事故表明存在问题点需重点排查',
                        weight: '高'
                    });
                    suggestions.push('<strong>事故复盘机制</strong>：对历史事故进行深度分析，制定针对性防范措施');
                }
                
                // 月季度高峰风险
                if (data.monthEnd) riskScore += 8;
                if (data.quarterEnd) riskScore += 10;
                
                // 确保分数在0-100之间
                riskScore = Math.max(0, Math.min(100, riskScore));
                
                // 确定风险等级
                let riskLevel = '低风险';
                if (riskScore >= 70) riskLevel = '高风险';
                else if (riskScore >= 50) riskLevel = '中风险';
                
                return {
                    riskScore,
                    riskLevel,
                    riskFactors,
                    suggestions,
                    roadSuggestions,
                    peakMonths: {
                        in: data.inMonth,
                        out: data.outMonth
                    }
                };
            }
            
            function displayAnalysisResults(analysis) {
                // 更新风险评分
                document.getElementById('risk-score-value').textContent = analysis.riskScore;
                document.getElementById('risk-level').textContent = analysis.riskLevel;
                document.getElementById('risk-level').className = 
                    analysis.riskScore >= 70 ? 'score-value score-high' : 
                    analysis.riskScore >= 50 ? 'score-value score-medium' : 
                    'score-value score-low';
                
                // 更新风险日历
                generateRiskCalendar(analysis.peakMonths.in, analysis.peakMonths.out);
                
                // 生成风险因素
                const riskFactorsContainer = document.getElementById('risk-factors');
                riskFactorsContainer.innerHTML = '';
                
                analysis.riskFactors.forEach(factor => {
                    const factorElement = document.createElement('div');
                    factorElement.className = 'risk-factor';
                    
                    const levelClass = `factor-${factor.level}`;
                    
                    factorElement.innerHTML = `
                        <div class="factor-header">
                            <div class="factor-icon ${levelClass}">
                                <i class="fas fa-${factor.level === 'critical' ? 'exclamation-circle' : 'exclamation-triangle'}"></i>
                            </div>
                            <h4>${factor.name}</h4>
                        </div>
                        <p>${factor.desc}</p>
                        <div style="margin-top: 10px; font-size: 0.85rem;">
                            <span class="risk-badge ${levelClass}">风险权重: ${factor.weight}</span>
                        </div>
                    `;
                    
                    riskFactorsContainer.appendChild(factorElement);
                });
                
                // 生成防控建议
                const suggestionsContainer = document.getElementById('prevention-suggestions');
                suggestionsContainer.innerHTML = `
                    <h4>企业级安全管理建议</h4>
                    <ul>
                        <li><strong>驾驶员培训计划</strong>：每季度进行防御性驾驶培训，重点训练盲区认知和紧急避险</li>
                        ${analysis.suggestions.map(s => `<li>${s}</li>`).join('')}
                        <li><strong>风险地图系统</strong>：建立工厂周边事故热力图，每月更新高风险点位</li>
                    </ul>
                    
                    <h4>技术性预防措施</h4>
                    <ul>
                        <li><strong>智能监控系统</strong>：在主要出入口安装AI摄像头，自动识别超速、违规变道行为</li>
                        <li><strong>车载安全设备</strong>：强制安装盲点监测、车道偏离预警和自动紧急制动系统</li>
                        <li><strong>电子围栏系统</strong>：在厂区周边500米设置限速区，超速自动警报</li>
                    </ul>
                `;
                
                // 生成道路建议
                const roadContainer = document.getElementById('road-suggestions');
                roadContainer.innerHTML = `
                    <ul>
                        ${analysis.roadSuggestions.length > 0 ? 
                         analysis.roadSuggestions.map(r => `<li>${r}</li>`).join('') : 
                         '<li>当前道路环境较好，建议维持现有安全措施</li>'}
                        <li><strong>路口安全改造</strong>：在事故多发路口增设右转警示区、行人安全岛</li>
                        <li><strong>夜间照明升级</strong>：在重要路口增加2000流明以上高亮度LED照明</li>
                    </ul>
                `;
            }
            
            function generateRiskCalendar(peakInMonth, peakOutMonth) {
                const calendarDiv = document.getElementById('risk-calendar');
                calendarDiv.innerHTML = '';
                
                const months = [
                    {name: '1月', num: 1},
                    {name: '2月', num: 2},
                    {name: '3月', num: 3},
                    {name: '4月', num: 4},
                    {name: '5月', num: 5},
                    {name: '6月', num: 6},
                    {name: '7月', num: 7},
                    {name: '8月', num: 8},
                    {name: '9月', num: 9},
                    {name: '10月', num: 10},
                    {name: '11月', num: 11},
                    {name: '12月', num: 12}
                ];
                
                months.forEach(month => {
                    const monthBox = document.createElement('div');
                    monthBox.className = 'month-box';
                    
                    let riskClass = 'low-risk';
                    let riskTag = '低风险';
                    
                    if (month.num == peakInMonth || month.num == peakOutMonth) {
                        riskClass = 'high-risk';
                        riskTag = '高风险';
                    } else if ([3, 6, 9, 12].includes(month.num)) {
                        riskClass = 'medium-risk';
                        riskTag = '中风险';
                    }
                    
                    monthBox.innerHTML = `
                        <div class="month-name">${month.name}</div>
                        <div class="risk-tag ${riskClass}">${riskTag}</div>
                    `;
                    
                    calendarDiv.appendChild(monthBox);
                });
            }
            
            function generateReportContent() {
                const companyName = document.getElementById('company-name').value || '企业';
                const riskLevel = document.getElementById('risk-level').textContent;
                const riskScore = document.getElementById('risk-score-value').textContent;
                const riskFactors = Array.from(document.querySelectorAll('.risk-factor')).map(el => el.outerHTML).join('');
                const preventionSuggestions = document.getElementById('prevention-suggestions').innerHTML;
                const priorityBox = document.querySelector('.priority-box').innerHTML;
                
                return `
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>${companyName}货运风险评估报告</title>
    <style>
        body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; line-height: 1.6; color: #333; max-width: 1000px; margin: 0 auto; padding: 30px; }
        h1, h2, h3 { color: #2c3e50; }
        h1 { text-align: center; margin-bottom: 20px; font-size: 28px; border-bottom: 2px solid #3498db; padding-bottom: 15px; }
        .section { margin-bottom: 30px; }
        .risk-level { text-align: center; font-size: 24px; margin: 30px 0; }
        .risk-high { color: #e74c3c; }
        .risk-medium { color: #f39c12; }
        .risk-low { color: #27ae60; }
        .info-table { width: 100%; border-collapse: collapse; margin: 20px 0; }
        .info-table th, .info-table td { border: 1px solid #ddd; padding: 12px; text-align: left; }
        .info-table th { background-color: #f8f9fa; font-weight: bold; }
        .recommendation { background: #e8f4fc; padding: 20px; border-left: 5px solid #3498db; margin: 20px 0; }
        .priority { background: #fff8e1; border-left: 5px solid #ffc107; padding: 15px; margin: 20px 0; }
        .footer { text-align: center; margin-top: 50px; color: #7f8c8d; font-size: 14px; }
        .calendar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 20px 0; }
        .calendar-item { padding: 10px; border: 1px solid #eee; text-align: center; }
        .calendar-high { background-color: rgba(231, 76, 60, 0.1); color: #e74c3c; font-weight: bold; }
        .calendar-medium { background-color: rgba(243, 156, 18, 0.1); color: #f39c12; }
        .calendar-low { background-color: rgba(39, 174, 96, 0.1); color: #27ae60; }
        .page-break { page-break-before: always; }
    </style>
</head>
<body>
    <h1>${companyName}货运风险评估报告</h1>
    
    <div class="section">
        <h2>报告摘要</h2>
        <p>本报告基于对${companyName}货运活动的全面评估，旨在识别关键风险点并提供具体预防措施。评估时间: ${new Date().toLocaleDateString('zh-CN')}</p>
        
        <div class="risk-level">
            综合风险评级: <span class="${riskLevel === '高风险' ? 'risk-high' : riskLevel === '中风险' ? 'risk-medium' : 'risk-low'}">${riskLevel}</span>
        </div>
        
        <p>风险评分: ${riskScore}/100</p>
    </div>
    
    <div class="section">
        <h2>企业基本信息</h2>
        <table class="info-table">
            <tr>
                <th>企业名称</th>
                <td>${companyName}</td>
                <th>所属行业</th>
                <td>${document.getElementById('industry').options[document.getElementById('industry').selectedIndex]?.text || '未选择'}</td>
            </tr>
            <tr>
                <th>年货运量</th>
                <td>${document.getElementById('annual-volume').value || '0'} 吨</td>
                <th>自有货车数量</th>
                <td>${document.getElementById('fleet-size').value || '0'} 辆</td>
            </tr>
            <tr>
                <th>高峰进货月份</th>
                <td>${document.getElementById('peak-in-month').options[document.getElementById('peak-in-month').selectedIndex]?.text || '未选择'}</td>
                <th>高峰出货月份</th>
                <td>${document.getElementById('peak-out-month').options[document.getElementById('peak-out-month').selectedIndex]?.text || '未选择'}</td>
            </tr>
        </table>
    </div>
    
    <div class="section">
        <h2>关键风险因素分析</h2>
        <div class="risk-factors">
            ${riskFactors}
        </div>
    </div>
    
    <div class="section">
        <h2>月度风险分布</h2>
        <div class="calendar">
            ${document.getElementById('risk-calendar').innerHTML}
        </div>
    </div>
    
    <div class="recommendation">
        <h2>综合防控建议</h2>
        ${preventionSuggestions}
    </div>
    
    <div class="priority">
        <h2>高优先级防控措施</h2>
        ${priorityBox}
    </div>
    
    <div class="footer">
        <p>本报告仅基于提供信息分析得出，建议每季度更新评估</p>
        <p>生成时间: ${new Date().toLocaleString('zh-CN')}</p>
    </div>
</body>
</html>
                `;
            }
        });
    </script>
</body>
</html>